/**
\file IO.h
*/
#pragma once
#include <lostlbase.h>
#include "System.h"

namespace lo {

	/**
	All functions here are static because kernel32 is always guaranteed to be loaded.
	const char * is UTF8 which is translated to wstring.
	*/
	class Kernel32
	{
	public:
		static bool				copyFile( _In_ const char *existingFileName, _In_ const char *newFileName, _In_ BOOL failIfExists );
		static bool				createDirectory( _In_ const char *pathName, _In_opt_ LPSECURITY_ATTRIBUTES securityAttributes = nullptr );
		static HANDLE			createFile( _In_ const char *fileName, _In_ DWORD dwDesiredAccess, _In_ DWORD dwShareMode, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes,
								_In_ DWORD dwCreationDisposition, _In_ DWORD dwFlagsAndAttributes, _In_opt_ HANDLE hTemplateFile );
		static vector<string>	enumResourceNames( _In_ const char *lpszType, _In_opt_ HMODULE hModule = NULL );
		static string			expandEnvironmentStrings( const char *in );
		static HRSRC			findResource( _In_opt_ HMODULE hModule, _In_ const char *name, _In_ const char * resType );
		static string			getCommandLine(void);
		static string			getCurrentDirectory();
		static int				getLocaleInfoNumber( LCID Locale, LCTYPE LCType, DWORD &data );
		static int				getLocaleInfoString( LCID Locale, LCTYPE LCType, string &data );
		static string			getPrivateProfileString( const char *fileName, const char *sectionName, const char *keyName, const char *defaultValue = "" );
		static vector<string>	getPrivateProfileKeyNames( const char *fileName, const char *sectionName );
		static vector<string>	getPrivateProfileSectionNames( const char *fileName );
		static string			getSystemDirectory();
		static string			getWindowsDirectory();
		static bool				isWow64Process();
		static HMODULE			loadLibraryEx(const char *fileName, DWORD flags);
		/** UTF8 friendly version of RemoveDirectoryW. The directory must be empty and the user must have delete access. */
		static bool				removeDirectory( _In_ const char *pathName );
		/** UTF8 friendly version of SetEnvironmentVariable */
		static bool				setEnvironmentVariable( _In_ const char *name, _In_ const char *value );
		/** UTF8 friendly version of WritePrivateProfileString */
		static bool				writePrivateProfileString( _In_ const char *fileName, _In_ const char *section, _In_ const char *key, _In_ const char *rvalue );
	};

}
